package com.haierCamera.customapplication.utils;

import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.widget.TextView;

/**
 * Created by AdministratorZJ
 * on 2020/6/28.
 */
public class EditTextChangeBoolean {
    private boolean enable = false;

    public interface EditTextChange {
        void isEnable(boolean enable);
    }

    public void buttonEnable(TextView view, EditTextChange change) {
        view.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String text = s.toString();
                change.isEnable(!TextUtils.isEmpty(text));
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

}
